import Vue from 'vue'
import moment from 'moment'

// Vue.filter('format',(value,time='YYYY-MM-d HH:mm:ss')=>{ // 默认值,没传参就用默认值,传参了就用传了的值
// 	console.log(value)
// 	return moment(value).format(time);
// })

Vue.filter('format',(value)=>{ 
	return formatFn(value)
})

function formatFn(value){
	let date = new Date(value)
	let year = date.getFullYear(value)
	let month = (date.getMonth(value) + 1).toString().padStart(2,'0')
	let day = date.getDate(value).toString().padStart(2,'0')
	let hours = date.getHours(value).toString().padStart(2,'0')
	let minute = date.getMinutes(value).toString().padStart(2,'0')
	let seconds = date.getSeconds(value).toString().padStart(2,'0')
	return `${year}-${month}-${day}- ${hours}:${minute}:${seconds}`
}